package com.campuscarbooking.api.listener;

import com.campuscarbooking.api.config.RabbitMQConfig;
import com.campuscarbooking.api.dto.message.CacheConsistencyMessage;
import com.campuscarbooking.api.service.CacheConsistencyService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class CacheConsistencyListener {

    private final CacheConsistencyService cacheConsistencyService;

    @RabbitListener(queues = RabbitMQConfig.CACHE_CONSISTENCY_QUEUE)
    public void handleCacheConsistencyMessage(CacheConsistencyMessage message) {
        log.info("Received cache consistency message: {}", message);
        cacheConsistencyService.handleCacheConsistencyMessage(message);
    }
} 